﻿using System;

namespace BorgExt.Behaviors
{
    public class Pair<T1, T2>
        where T1 : class
        where T2 : class
    {
        private readonly T1 _first;
        private readonly T2 _second;

        public Pair(T1 first, T2 second)
        {
            if (first == null)
                throw new ArgumentNullException("first");

            if (second == null)
                throw new ArgumentNullException("second");

            _first = first;
            _second = second;
        }

        public override bool Equals(object obj)
        {
            if (obj == this)
                return true;

            if (!(obj is Pair<T1, T2>))
                return false;

            var pair = (Pair<T1, T2>)obj;

            return _first.Equals(pair._first) && _second.Equals(pair._second);
        }

        public override int GetHashCode()
        {
            return _first.GetHashCode() ^ _second.GetHashCode();
        }

        public T1 First
        {
            get { return _first; }
        }

        public T2 Second
        {
            get { return _second; }
        }
    }
}

